-- @owner: zou_jialiang050
-- @date: 2024-07-06
-- @testpoint: create table as select

--step1:建表;expect:成功
drop sequence if exists seq_ustore_regr_sxy_021 cascade;
create sequence seq_ustore_regr_sxy_021 increment by 1 start with 10;
drop table if exists t_ustore_regr_sxy_021 cascade;
create table  t_ustore_regr_sxy_021(
     col_1 integer,
     col_2 number(19,0),
     col_3 number(10,6)
) with (storage_type=ustore);

begin
	for i in 1..50 loop
      insert into t_ustore_regr_sxy_021 values(
	  i,
      seq_ustore_regr_sxy_021.nextval,
	  i+445.255
	  );
    end loop;
end;
/

--step2:create table as select;expect:成功
drop table if exists t_ustore_regr_sxy_021_1;
create table t_ustore_regr_sxy_021_1 with (storage_type=ustore) as select regr_sxy(col_2,col_2) as a from t_ustore_regr_sxy_021 group by col_1,col_2,col_3;
select * from t_ustore_regr_sxy_021_1 order by 1 limit 10;
drop table if exists t_ustore_regr_sxy_021_1;
create table t_ustore_regr_sxy_021_1 with (storage_type=ustore) as select regr_sxy(col_2-col_3,col_2-col_3) as a from t_ustore_regr_sxy_021;
select * from t_ustore_regr_sxy_021_1 order by 1;

--step3:清理环境;expect:成功
drop sequence if exists seq_ustore_regr_sxy_021 cascade;
drop table if exists t_ustore_regr_sxy_021_1 cascade;
drop table if exists t_ustore_regr_sxy_021 cascade;